home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST9-18.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  885b  |  35 lines

  1. ;
  2. ; *** Listing 9-18 ***
  3. ;
  4. ; Supports the use of CX to store a loop count and CL
  5. ; to store a shift count by using XCHG to swap the
  6. ; contents of CL as needed.
  7. ;
  8.     jmp    Skip
  9. ;
  10. ARRAY_LENGTH    equ    1000
  11. Array1    db    ARRAY_LENGTH dup (3)
  12. Array2    db    ARRAY_LENGTH dup (2)
  13. ;
  14. Skip:
  15.     mov    si,offset Array1 ;point to the source array
  16.     mov    di,offset Array2 ;point to the dest array
  17.     mov    ax,ds
  18.     mov    es,ax        ;copy to & from same segment
  19.     mov    cx,ARRAY_LENGTH    ;the loop count
  20.     mov    dl,2        ;the shift count
  21.     call    ZTimerOn
  22. ProcessingLoop:
  23.     lodsb            ;get the next byte
  24.     xchg    cl,dl        ;get the shift count into CL
  25.                 ; and save the low byte of
  26.                 ; the loop count in DL
  27.     shl    al,cl        ;shift the byte
  28.     xchg    cl,dl        ;put the shift count back
  29.                 ; into DL and restore the
  30.                 ; low byte of the loop count
  31.                 ; to CL
  32.     stosb            ;save the modified byte
  33.     loop    ProcessingLoop
  34.     call    ZTimerOff
  35.